library(gganimate)
library(ggplot2)
library(maps)
library(ggthemes)
setwd("~/OneDrive - Indiana University/FromGoogle/DeforestationDisease/CodeFinal_12_5_24/")
####Read the disease data
dis.dat <- read.csv("datplot.csv")
summary(dis.dat)

##Define countries to be plotted
african.countries <- c(
  "Algeria","Angola","Benin","Botswana","Burkina Faso","Burundi","Cabo Verde",
  "Cameroon","Central African Republic","Chad","Comoros","Democratic Republic of the Congo",
  "Republic of Congo","Ivory Coast","Djibouti","Egypt","Equatorial Guinea",
  "Eritrea","Eswatini","Ethiopia","Gabon","Gambia","Ghana","Guinea","Guinea-Bissau",
  "Kenya","Lesotho","Liberia","Libya","Madagascar","Malawi","Mali","Mauritania","Mauritius",
  "Morocco","Mozambique","Namibia","Niger","Nigeria","Rwanda","Sao Tome and Principe",
  "Senegal","Seychelles","Sierra Leone","Somalia","South Africa","South Sudan",
  "Sudan","Tanzania","Togo","Tunisia","Uganda","Zambia","Zimbabwe", "Swaziland", "Western Sahara"
)

###Import forest data
forest <- read.csv("forestdatjaxa124.csv")
##############
###Plot map###
##############
#Begin with a map of the African states
world <- ggplot() +
  borders("world", regions=african.countries, colour = "gray85", fill = "gray80") +
  theme_map() 

#Color scale
cc <- scales::seq_gradient_pal("red", "blue", "Lab")(seq(0,1,length.out=19))

##Create the main map
map.all.col <- world +
  #Disasters
  geom_point(aes(x = longitude, y = latitude, alpha=`Forest.coverage`),
             data = forest, pch=15, size=0.8, colour='darkgreen', show.legend = FALSE) +
  #scale_fill_continuous(breaks=c(0,0.25,0.5,0.75,1), labels=c("0%", "25%", "50%","75%","100%")) +
  geom_point(aes(x = Longitude, y = Latitude, color = Pathogen), size=0.75,
             data = dis.dat) +
  scale_colour_manual(values=cc)+
  theme(legend.position = "bottom")
  

##Export map
setwd("~/OneDrive - Indiana University/FromGoogle/DeforestationDisease/")
jpeg("figures1.jpeg", width = 6, height = 6, units = 'in', res = 500)
map.all.col
dev.off()

                             

                                                  



